<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>网点查询</title>

        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">

        <!-- BootStrap CSS -->
        <link href="css/bootstrap.css"         rel="stylesheet" type="text/css">
        <link href="themes/default/easyui.css" rel="stylesheet" type="text/css">
        <link href="themes/icon.css"           rel="stylesheet" type="text/css">

        <!-- JavaScript EasyUI -->
        <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
        <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="js/easyloader.js"></script>

        <!-- Action Function -->
        <script type="text/javascript">
        function mes(a, b, c) {
            alert(a + b + c);
        };
        
        $(function() {
        
            $("#queryButton").click(function() {
        
                var i = 1;
        
                $(".easyui-validatebox").each(function() {
                    if ($(this).val() == "") {
                        mes('系统提示', '请把信息填写完整!', 'warning');
                        i = 0;
                        return false;
                    }
                });
        
                if (i == 1) {
                    ajaxSubmit();
                }
            });
        });
        
        function removeUnTimeFormat(time){
            time.replace(':','');
        }
        
        function removeTimeFormat(time){
            var timeFormat = time.substring(0,2) + ':' + time.substring(2,4);
            return timeFormat;
        }

        function ajaxSubmit() {

            var networkName = $('#networkName').val();
            var networkParkSize = $('#networkParkSize').val();
            var networkProvince = $('#networkProvince').val();
            var networkCity = $('#networkCity').val();
            var networkArea = $('#networkArea').val();
            var networkAddress = $('#networkAddress').val();
            var networkPrice = $('#networkPrice').val();
            var networkTimeBegin = removeUnTimeFormat($('#networkTimeBegin').val());
            var networkTimeEnd = removeUnTimeFormat($('#networkTimeEnd').val());
            var networkType = $('#networkType').find('option:selected').attr('value');

            //get parameter
            var netWorkStr = {
                networkName : networkName,
                networkParkSize : networkParkSize,
                networkProvince : networkProvince,
                networkCity : networkCity,
                networkArea : networkArea,
                networkAddress : networkAddress,
                networkPrice : networkPrice,
                networkTimeBegin : networkTimeBegin,
                networkTimeEnd : networkTimeEnd,
                networkType : networkType
            }

            $.ajax({type:"post",
                       dataType:"text",
                       timeout:30000,
                       async:true,
                       url:"admin/query_network_add_park.do",
                       data:{netWorkStr:JSON.stringify(netWorkStr)},
                       contentType: "application/x-www-form-urlencoded; charset=utf-8",
                       success:function (data) {

                            var resultMap =  eval('(' + data + ')');

                            if (resultMap.netWorkList.length > 0 ) {

                                $('#detail').empty();

                                var html = '查询到 '+resultMap.netWorkList.length+'条记录';

                                $.each(resultMap.netWorkList, function(i,netWork){
                                    html += ' <table border="1px" cellspacing="0px" class="table">                                                        ';
                                    html += '   <tr>                                                                                                      ';
                                    html += '       <td rowspan="3" class="success" width="30%"><p class="success" >' + netWork.networkName + '</p></td>  ';
                                    html += '       <td colspan="2">网点总车位:'+ netWork.networkParkSize +' (个)</td>                                                  ';
                                    html += '       <td rowspan="3" align="right" valign="middle" style="line-height:100px "><a class="btn btn-primary" href="admin/add_park/'+netWork.networkId+'.do"><i class="icon-align-right"></i>添加车位</a></td>                 ';
                                    html += '   </tr>                                                                                                     ';
                                    html += '   <tr>                                                                                                      ';
                                    html += '       <td>网点营业开始时间：'+ removeTimeFormat(netWork.networkTimeBegin) +'</td>';
                                    html += '       <td>网点地址:' + netWork.networkProvince + netWork.networkCity + netWork.networkArea + netWork.networkAddress + '</td>';
                                    html += '   </tr>                                                                                                     ';
                                    html += '   <tr>                                                                                                      ';
                                    html += '       <td>网点营业结束时间：'+ removeTimeFormat(netWork.networkTimeEnd) +'</td>';
                                    html += '       <td>网点单价:'+ netWork.networkPrice +' (元/小时)</td>                                                            ';
                                    html += '   </tr>                                                                                                     ';
                                    html += ' </table>                                                                                                    ';
                                });
                                $('#detail').append(html);
                            } else {
                                $('#detail').empty();
                                $('#detail').append('查询无结果');
                            }
                       },
                       error:function (XMLHttpRequest, textStatus, errorThrown) {
                           console.log(XMLHttpRequest.status);
                           console.log(XMLHttpRequest.readyState);
                           console.log(textStatus);
                       }
        });
    }
    </script>
    </head>

    <body>
        <div>
            <p class="bg-primary"> 查询选择网点</p>
            <table class="table">
                <tr>
                    <td>
                        <table width="950px">
                            <tr>
                                <td>网点名称：</td>
                                <td>
                                    <input id="networkName" name="networkName" type="text"
                                        class="input-medium search-query" />
                                </td>
                                <td>网点车位数量：</td>
                                <td>
                                    <input id="networkParkSize" name="networkParkSize" type="text"
                                        class="input-medium search-query" />
                                </td>
                                <td>网点省份：</td>
                                <td>
                                    <input id="networkProvince" id="networkProvince" type="text"
                                        class="input-medium search-query" name="networkProvince" />
                                </td>
                            </tr>
                            <tr>
                                <td>网点城市：</td>
                                <td>
                                    <input id="networkCity" type="text"
                                        class="input-medium search-query" name="networkCity" />
                                </td>
                                <td>网点地区：</td>
                                <td>
                                    <input id="networkArea" type="text"
                                        class="input-medium search-query" name="networkArea" />
                                </td>
                                <td>网点价格（元/小时）： </td>
                                <td>
                                    <input id="networkPrice" name="networkPrice" type="text"
                                        class="input-medium search-query" />
                                </td>
                            </tr>
                            <tr>
                                <td>网点营业时间开始：</td>
                                <td>
                                    <input id="networkTimeBegin" name="networkTimeBegin"
                                        type="text" class="easyui-timespinner" type="text"
                                        value="08:00" />
                                </td>
                                <td>网点营业结束时间：</td>
                                <td>
                                    <input id="networkTimeEnd" name="networkTimeEnd" type="text"
                                        class="easyui-timespinner" type="text" value="20:00" />
                                </td>
                                <td>网点类型：</td>
                                <td>
                                    <select id="networkType" name=”networkType”
                                        class=”easyui-combobox” style="">
                                        <option id="1" value="1" selected="selected">普通网点</option>
                                    </select>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <td width="100px">
                            <table width="50px">
                                <tr>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <button id="queryButton" name="queryButton" type="button" class="btn" value="查询">查询</button>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </td>
                </tr>
            </table>
            <div>
                <div id="detail">
                </div>
            </div>
        </div>
    </body>
</html>
